News:

One Minute Game Review by The Happy Friar: https://ugetube.com/@OneMinteGameReviews
Also on Rumble: https://rumble.com/c/c-1115371

idTech 4 (aka Doom 3 tech) Discord Server! https://discord.gg/9wtCGHa

Main Menu

Simple moving platform script...

Started by douglas quaid, December 17, 2015, 09:16:06 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

douglas quaid

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


The Happy Friar

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

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?

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

Do you run that function in your main function?

douglas quaid

Yeah, I think so... :(

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

#6
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?

douglas quaid

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


douglas quaid

In the editor I created 'func_mover_1' for the platform I want to move. Below is everything I have in the script file.

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

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

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

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

You have it happens once.  You need it in a loop. 
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

#14
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...
// 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?
TOTAL RECALL - Singleplayer mod for Doom 3 starring Arnold Schwarzenegger
BLACKOUT - Free indie horror game based on the id Tech 4 engine