Author Topic: Simple moving platform script...  (Read 751 times)

0 Members and 1 Guest are viewing this topic.

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Simple moving platform script...
« on: December 17, 2015, 09:16:06 PM »
Hey guys.

As I've just started modding again after a long absence, I appear to have forgotten how to code (script). I was wondering what script I would need to make a moving platform ie. moves on it's own with no triggers when the level loads. Also, what code do I need to add to the script file for the mover to move forward, and then move back to it's starting point, and then repeatedly do so while the level is being played. I know this is probably very basic for most of you but I do forget sometimes, and I've done a search but haven't found what I'm looking for. :D

Thanks,

Quaid.
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine

MrC

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +8/-23
  • Doom Newbie
    • View Profile
Re: Simple moving platform script...
« Reply #1 on: December 17, 2015, 11:51:44 PM »
https://www.3dbuzz.com/training/view/doom-3-modding/series-2/controlling-movers Hopefully this might be a good refresher for what you're looking for.

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 825
  • Karma: +37/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #2 on: December 18, 2015, 08:37:37 AM »
Man, 20 minutes?  I'm impatient.  :)

Assuming you remember how to use Radiant, here's a quicky:

1) make your func_mover.  BE SURE it's a func_mover.  Func_static's work too but they don't work correctly when moving (had lots of fun with this years ago!)

2) THE CHEATER WAY: put a target_null where you want mover to go.  Put a target_null where you want the target_null to start (most likely where you create the func_mover).

3) set the settings on the func_mover for speed, time, accel, whatever.  D3RAdiant has info on what each means.

4) jot down the names of the func_mover & the null's.

5) Save the map.

6) make a .script file in the same folder as the map.  IE if the map is "maps/game/mover.map" put the script in "maps/game/mover.script"

7) setup your script.

I've attached an example map & script for you.   I also recommend the handy dandy D3 script help file: http://www.moddb.com/members/thehappyfriar/downloads/doom-3-reference-page

Just extract the .zip to your maps folder & dmap it and it will work.

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #3 on: December 19, 2015, 05:44:58 AM »
Thanks for the help guys. That map Friar is also appreciated, but when I tried the target null approach it doesn't seem to work for me. Maybe I'm doing something wrong... I've tried this also and am getting no results, any ideas?

Code: [Select]
void platform_1()
{
sys.wait(2);
$platform_1.moveToPos('2672 832 -488');
sys.waitFor($platform_1);
sys.wait(3);
$platform_1.moveToPos('1584 832 -488');
sys.waitFor($platform_1);
}
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 825
  • Karma: +37/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #4 on: December 19, 2015, 08:11:24 AM »
Do you run that function in your main function?

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #5 on: December 19, 2015, 09:01:37 AM »
Yeah, I think so... :(

Code: [Select]
void main ()
{

// Call Moving Platform to function
func_mover_1 ();
}
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine

MrC

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +8/-23
  • Doom Newbie
    • View Profile
Re: Simple moving platform script...
« Reply #6 on: December 19, 2015, 02:32:36 PM »
The name of the function you're calling in main is "func_mover_1 ();" but the name of the function is "void platform_1()", perhaps that might be why it isn't working for you?
« Last Edit: December 19, 2015, 02:34:48 PM by MrC »

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #7 on: December 19, 2015, 04:13:20 PM »
Good point MrC but I have changed it around and is still not working. :(
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 825
  • Karma: +37/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #8 on: December 19, 2015, 04:59:42 PM »
Please post the whole script file.

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #9 on: December 20, 2015, 02:08:39 AM »
In the editor I created 'func_mover_1' for the platform I want to move. Below is everything I have in the script file.

Code: [Select]
void main ()
{

// Call Moving Platform to function
func_mover_1 ();

}


/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// Moving Platform

void func_mover_1 ()
{
sys.wait(2);
$func_mover_1.moveToPos('2672 832 -488');
sys.waitFor($func_mover_1);
sys.wait(3);
$func_mover_1.moveToPos('1584 832 -488');
sys.waitFor($func_mover_1);
}
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine

MrC

  • Jr. Member
  • **
  • Posts: 56
  • Karma: +8/-23
  • Doom Newbie
    • View Profile
Re: Simple moving platform script...
« Reply #10 on: December 20, 2015, 03:36:43 AM »
Ah, ok. As per this: http://www.3dbuzz.com/training/view/doom-3-modding/series-2/intro-to-functions

It's mentioned in the video that the main() function should always be the last function in the script, so just put main at the bottom instead of the top and hopefully that'll get it working.

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 825
  • Karma: +37/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #11 on: December 20, 2015, 07:55:07 AM »
I'd also highly suggest you NOT have function names the same as any entity in the map.  It might be an issue.  I know (though testing) that there's certain reserved key works for scripts & you can't use those names in variable/function names, but it's always been a hit and miss to find them. 

I'd say MrC is right, put the main at the end and it should work.

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #12 on: December 20, 2015, 11:45:45 AM »
Thanks guys. What MrC advised seemed to work but the platform only travels to the first position. What do you think is preventing it from traveling to the return position and then looping both phases?
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine

The Happy Friar

  • Happy Happy Joy Joy
  • Administrator
  • Hero Member
  • *****
  • Posts: 825
  • Karma: +37/-4
  • Semi-Newbie.
    • View Profile
    • EarthQuake
Re: Simple moving platform script...
« Reply #13 on: December 20, 2015, 02:29:00 PM »
You have it happens once.  You need it in a loop. 
Code: [Select]
void moving ()
{
    while (1)
        {
            $func_mover_1.moveTo($target_null_2);
            sys.waitFor($func_mover_1);
            $func_mover_1.moveTo($target_null_1);
            sys.waitFor($func_mover_1);
        }
}

The while(1) keeps going until 1 isn't true.  Since 1 is always true because I'm not changing it, it always loops.

douglas quaid

  • Jr. Member
  • **
  • Posts: 88
  • Karma: +6/-8
  • Level Designer/Sound Designer
    • View Profile
    • Total Recall
Re: Simple moving platform script...
« Reply #14 on: December 20, 2015, 06:05:57 PM »
Edited...

Worked a treat Mr. Friar :D but I have another problem...

I tried adding a second mover but this one doesn't work even when I used the same code...
Code: [Select]
// Moving Platform 1

void platform_1 ()
{
        while(1)
{
$platform_1.moveToPos('2672 832 -488');
sys.waitFor($platform_1);
sys.wait(.001);
$platform_1.moveToPos('1584 832 -488');
sys.waitFor($platform_1);
sys.wait(.001);
}

}


// Moving Platform 2

void platform_2 ()
{
        while(1)
{
$platform_2.moveToPos('1584 832 280');
sys.waitFor($platform_2);
sys.wait(.001);
$platform_2.moveToPos('2672 832 280');
sys.waitFor($platform_2);
sys.wait(.001);
}

}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////



void main ()
{
// Call Moving Platform 1 to function
platform_1 ();

// Call Moving Platform 2 to function
platform_2 ();
}

What do you think?
« Last Edit: December 20, 2015, 07:45:05 PM by douglas quaid »
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine