Jump to content
The Dark Mod Forums

repeat called script until condition is met.


teh_saccade

Recommended Posts

Hi,

I am sketching out a searchlight tower, to which I want to assign some functions.

It is, so far, using:

- tower model, with searchlight rail.
- AI archer (idk how to get them to use ladders - monsterclip?).

The lights are small boxes:

- searchlight brush/patch model, to travel rail.
- projected light entities (searchlights)
- emitter (lamplight)

Bind with:

- func_mover (nodraw, anchor)

Triggered by:

- trigger_once / trigger_multiple

That calls:

- script "searchlight"

Here is the current map script:

 
   
//called by triggerN, to send func_moverN: anchor(+light+emitter) along curve originating in func_static: splineN

void searchlight()

{
        $anchor.time(40);
        $anchor.accelTime(.1);
        $anchor.decelTime(.1);

        $anchor.startSpline($spline1);

        
//spine2, anterotation, is to direct searchlight in correct direction

        $anchor.time(40);
        $anchor.accelTime(.1);
        $anchor.decelTime(.1);

        $anchor.startSpline($spline2);
        
        
}

void main()
{
}


- "splineN" is map entity: func_static with value: curve_CatmullRomSpline (nodraw, splineN).

If I only use 1 spline in teh animation, the light is flipped at the start 180. So I had to include 2, in order to keep the direction of the beam correct.

That's the basic light revolving and projection mechanism completed, along with a scripted path for the prefab components to move, that simulates a searchlight driven round a rail on at the top of the tower.

-----

I was controlling the script (searchlights moving) with a switch that turns on the lights and calls the script.

In order to start and loop teh script, I was using a trigger entity tied to a silent switch that would start open, auto-close (activate) after a 0.5 delay, then auto-open (deactivate) after 39.5.

This means the lights revolve like they should, work like they ought to, and then - when it reaches the end of the spline / script, the switch triggers and flips them back on again.
With a 0.5 delay, which is the fastest it seems to work to turn the lights on and off.
AND, it resets it to the start of the spline. Which means if you manually flip the switch, it turns on again with the lights back where they started instead of resuming from where they were...
AND, there's no way to turn it off... It turns back on all the time!!

I cannot figure it out with mapping switches, as I don't know how to get a switch to render another switch inoperable.

Perhaps if there is a way to lock another switch with a switch... Then it would be possible to turn it all off...

That'd be great, but it seems that it would be better and easier to loop the script somehow (the resume from state is not important if it is turned off and it's off forever - but the save game state is still needed), so that the switch calls "searchlight" script when on, and ends it when off.

That's something that will make it work properly.

For "emergency searchlights"...

I think I can get the thing to come on (and/or start revolving) only when there is a "need" by setting a hidden objective to do with being spotted that is activated at start of location. IrreversibleObjective, rather than trigger_once, calls searchlight if it fails, and objective is deactivated on leaving location.
Or
Maybe making startSpline dependant upon state of tdm_alarm and have the failing objective call this somehow...

Idk how to do that at all - this is pretty confusing stuff.

Anyway...

I need to figure out how to get it to loop, so that deactivating the switch stops everything - this dark delay in the middle is untidy and annoying, it always resets at the start (not such an issue) and it means that the player cannot turn it on and off in game :/

I was experimenting with this code but, unsurprisingly since this is my first experience with all this, it doesn't work:

#ifndef TESTPATH
#define TESTPATH

object searchlight

{
    void     init();
    float    m_updatePeriod;
    void     RestoreScriptObject();
    void    updateLoop();
};
    
//called by trigger, to send func_mover: anchor (+light+emitter) along curve originating in func_static: spline.

void searchlight::init()

{
   
        m_updatePeriod = getFloatKey ( "update_period");
        
        thread updateLoop();
};

void searchlight::RestoreScriptObject()

{
        $anchor.time(40);
        $anchor.accelTime(.1);
        $anchor.decelTime(.1);

        $anchor.startSpline($spline1);

        $anchor.time(40);
        $anchor.accelTime(.1);
        $anchor.decelTime(.1);

        $anchor.startSpline($spline2);
        
        m_updatePeriod = getFloatKey ( "update_period");
        
        updateLoop();
};

void searchlight::updateLoop()

{

    while(1)
    {
        if ()
        
        {
        wait ( m_updatePeriod );
        }
               
    }
}
   
#endif


but I do not know how to set the objects or the update periods or how to construct the updateLoop() or what the heck that even means.

Initially, I was working with the curves to try to path AI patrols in anything but a straight line.
Then I realised curves can be used for defining many other paths.

What I also need to find out, to include the things I imagine in these levels, is to be able to have an object move along a spline, but also rotate on its origin Z axis as it does it.

I've attached the .map and .script files for any that would care to look.
Don't worry about the wonky lights - that is because I rotated them too hastily. There are blocks up there to check direction. The splines need some playing with.

 

 

Sorry it's such a long post but, if I just wrote - how to I loop a script? Someone would reply, "updateLoop" and I would say, yeah but... and then... you know... wouldn't be able to ask if a switch can lock a switch and all that other stuff...


Can anyone point me in the right direction to find out how to do the switch locking switch, trigger object to rotate on its axis and the updateLoop thing, please?

The wiki is a little light in some areas.


Thanks!

Oh - I'm not allowed to upload files, here's a dropbox link instead: https://www.dropbox.com/s/62ogu2opfncyjk5/maps.zip?dl=0

  • Like 1
Link to comment
Share on other sites

Additionally, the DR wiki has this page on curves:

http://wiki.thedarkmod.com/index.php?title=NURBS_Curves

The link is dead.
There is a snapshot from 2005 from doom3world, which contains the tutorial and image links (now dead) which I have saved and used for reference.

I would be happy to update the article to latest version of DR, and replace the missing images.

Edited by teh_saccade
Link to comment
Share on other sites

regarding doom 3 world: https://web.archive.org/web/20120302232233/http://www.doom3world.org/index.php

 

Regarding your question, can you be a bit more specific on what you want in regard to the script. I didn't really get it reading through your wall of text :)

FM's: Builder Roads, Old Habits, Old Habits Rebuild

Mapping and Scripting: Apples and Peaches

Sculptris Models and Tutorials: Obsttortes Models

My wiki articles: Obstipedia

Texture Blending in DR: DR ASE Blend Exporter

Link to comment
Share on other sites

I discovered func_rotating for the z axis rotation, so that is sorted.

Sorry for the text, but I don't understand most of it, and garbling helps it make sense...


Specifically, either some clue with how to make a script loop continuously until the trigger is turned off.

Or,

Figuring a way to make a switch lock another switch.


I'm guessing that the script Stumpy has left is a piece to loop the script and i have to substitute the switch for whatever it's called in teh map.

Thanks Stumpy - I will try it out:)

  • Like 1
Link to comment
Share on other sites

Incidentally, would WaitFor also work for a speaker, waiting the time for it to finish playing a one-shot sound?

What do you see when you turn out the light? I can't tell you but I know that it's mine.

Link to comment
Share on other sites

Ok - I will try it now, thanks again.

The speaker would be great for the sound of the servos driving the motor, or something.
I will try that too.

However, I have a problem on my maps (except for soundpipe.pk4 that I posted elsewhere), in that the speakers are heard all over the map and - if waitfortrigger - dont respond to triggers.
Only the first sound will play, everywhere, and nothing else is heard.

Link to comment
Share on other sites

i am doing something wrong here...
The killswitch... hmmm

I will draw a quick schematic to try and understand how this works.

 

I am terrible with languages - been learning french, german, spanish and russian for ages and, while I have no trouble understanding the reading side - It is hard to construct my own statements and stuff in anything other than english or colours. brb.

Link to comment
Share on other sites

Objects in the area:

light1, starts off, bound to spline.

switch1 (searchlight, hidden) starts closed / activated.
this switch turns on the light, starts the light moving.

switch2 (killswithc, player will use) starts open / inactive.
this switch turns off the light, stops the light moving.

 



Code for objects:

floats "switch" as true

switch1 = searchlight, code moves anchor along spline, loops?

switch2 = killswitch, code ... idk what it does... sets boolean "switch" to false, so ending loop.


anyway:

 
float switch = true;
 
void searchlight()

{
        $anchor.time(40);
        $anchor.accelTime(.1);
        $anchor.decelTime(.1);

        $anchor.startSpline($spline1);
  
        $anchor.time(40);
        $anchor.accelTime(.1);
        $anchor.decelTime(.1);

        $anchor.startSpline($spline2);
 
        while ( switch == true )
                
       {
       loop;
       }
 
 
      
}
 
 

void killswitch()
 
{
switch = false;
}
 
 

void main()
{
}

Please bear in mind that thinking in code is very similar to orgasm for me.

Just an orgasm of pain and misery and suffering...


What am I doing wrong here guys?!

christ i have no idea how to figure out the sound thing... can the waitif be measured in time? or does it have to be a conditional related to the other scripts?

Am I gonna have to get a book on python to be able to map that's not an arena shooter?

Edited by teh_saccade
Link to comment
Share on other sites

You know what - last night i was showing my girlfriend around a level on skype and she was saying "why do you even need to stop the lights moving? just turn them off and then they won't reset."

And I said, "oh why didn't i thnk of that?"


Might be worth keeping the switch float open for something that needs it...Thanks for the help with the loop thing though! that's mega useful all over the place!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • nbohr1more

      The FAQ wiki is almost a proper FAQ now. Probably need to spin-off a bunch of the "remedies" for playing older TDM versions into their own article.
      · 1 reply
    • nbohr1more

      Was checking out old translation packs and decided to fire up TDM 1.07. Rightful Property with sub-20 FPS areas yay! ( same areas run at 180FPS with cranked eye candy on 2.12 )
      · 3 replies
    • taffernicus

      i am so euphoric to see new FMs keep coming out and I am keen to try it out in my leisure time, then suddenly my PC is spouting a couple of S.M.A.R.T errors...
      tbf i cannot afford myself to miss my network emulator image file&progress, important ebooks, hyper-v checkpoint & hyper-v export and the precious thief & TDM gamesaves. Don't fall yourself into & lay your hands on crappy SSD
       
      · 7 replies
    • OrbWeaver

      Does anyone actually use the Normalise button in the Surface inspector? Even after looking at the code I'm not quite sure what it's for.
      · 7 replies
    • Ansome

      Turns out my 15th anniversary mission idea has already been done once or twice before! I've been beaten to the punch once again, but I suppose that's to be expected when there's over 170 FMs out there, eh? I'm not complaining though, I love learning new tricks and taking inspiration from past FMs. Best of luck on your own fan missions!
      · 4 replies
×
×
  • Create New...