Jump to content
The Dark Mod Forums

STRUNK

Member
  • Posts

    479
  • Joined

  • Last visited

  • Days Won

    14

Posts posted by STRUNK

  1. I was working on a random self moving thing that can detect boundries and turn away from them. The boundries work with a stim/response where the stim is the boundry and the respons is on a "sensor" in front of the moving func_mover, that is controlled by the script. The sensor has the response to run a function called Warning (when toutching the stim).

    In my small scale test I got it working flawlessly, but when I scaled it up and put boundries tot the walls of a big room things went totally wrong: big drop in framerate and it didn't work flawless at all ... bummer : D

    Here is a video of the test setup working at high speed (framerate is down due to OBS running): VIDEO

    Here is the script, maybe someone can use (parts of) it in the future for something:

    Spoiler

    void Warning()
    {
        $Target1.stopMoving();
        $Warning.rotate( '0 0 720' );
    }

    void WarningStop()
    {
    while (1)
        {
        $Warning.stopRotating();
        sys.waitFrame();
        }
    }


    void Collision()
    {
            $Target1.rotateOnce('0 0 25');
    }


    void RotateRandom()
    {
        float minY = 0;            // Minimal Horizontal Turning Angle
        float maxY = 0;            // Maximal Horizontal Turning Angle
        float Y = minY + sys.random(maxY - minY);
        
        float minZ = -30;        // Minimal Vertical Turning Angle
        float maxZ = 30;        // Maximal Vertical Turning Angle
        float Z = minZ + sys.random(maxZ - minZ);
        
        vector R = ('0 0 0');
        R_y = R_y + Y;
        R_z = R_z + Z;
        
        $Target1.time (0.01);    //Turning Speed (Lower number is higher speed)
        
        $Target1.rotateOnce (R);
        sys.wait(0.01);            //Turning Frequency

    }

    void Move()
    {

        $Target1.speed (600);    //Moving Speed (600 seems max safe speed = 10units/frame)
        $Target1.move(REL_LEFT , 20);


    }

    void Rest()
    {

        $Target1.move(REL_LEFT , 0);


    }

    void MoveRest()
    {
        float minA = 0;
        float maxA = 1000;
        float A = minA + sys.random(maxA - minA);
            
            if (A>=0&&A<1)
            {
            Rest();
            sys.wait(1);
            }

            if (A>=1&&A<2)
            {
            Rest();
            sys.wait(5);
            }

            else
            {
            Move();
            }
            
        sys.waitFrame();
    }

    void MoveRestCol()
    {
    while(1)
        {
            if ($Warning.isRotating())
            {
            Collision();
            }
            else
            {
            MoveRest();
            }
            
        sys.waitFrame();
        }
    }

    void RotCol()
    {
    while(1)
        {
            if ($Warning.isRotating())
            {
            Collision();
            }
            else
            {
            RotateRandom();
            }
        sys.waitFrame();
        }
    }

    void main()
    {
        thread WarningStop();
        thread MoveRestCol();
        thread RotCol();
    }

     

    • Like 1
  2. @Dragofer

    If I getFrameTime() it returns 0.0160 so I guess that is the minimum time the engine can repeat/check things. But if I have a wait of 0.001 in a while() loop, it calculates every frame what would have happened in 16 times this while() loop .. right?

     

    I have a working script now and am determaning the right settings for maximum speed. Only problem is I can't get higher then a movement of 12 units in one loop, for it results in the enty escaping through the boundries: 

    Spoiler

    void Warning()
    {
        $Warning.rotate( '0 0 720' );
    }

    void WarningStop()
    {
    while (1)
        {
        $Warning.stopRotating();
        sys.wait(0.002);
        }
    }


    void Collision()
    {
    $light_4.On();

            $Target1.rotateOnce('0 0 15');
            sys.wait(0.001);
    $light_4.Off();
    }

    void Coll()
    {
    if ($Warning.isRotating())
    Collision();
    }

    void RotateRandom()
    {
        float minY = 0;
        float maxY = 0;
        float Y = minY + sys.random(maxY - minY);
        
        float minZ = -30;//-60
        float maxZ = 30;//60
        float Z = minZ + sys.random(maxZ - minZ);
        
        vector R = ('0 0 0');
        R_y = R_y + Y;
        R_z = R_z + Z;
        
        $Target1.time (0.1);
        
        $Target1.rotateOnce (R);
        sys.wait(0.2);
        float frmTime = sys.getFrameTime();
        sys.println (frmTime);
    }

    void Move()
    {

        $Target1.speed (1);
        $Target1.move(REL_LEFT , 12);
        sys.wait(0.001);

    }

    void Rest()
    {

        $Target1.move(REL_LEFT , 0);
        sys.waitFrame();

    }

    void MoveRest()
    {
        float minA = 0;
        float maxA = 1000;
        float A = minA + sys.random(maxA - minA);
            
            if (A>=0&&A<1)
            {
            Rest();
            sys.wait(1);
            }

            if (A>=1&&A<2)
            {
            Rest();
            sys.wait(5);
            }

            else
            {
            Move();
            }
            
        sys.wait(0.001);
    }

    void MoveRestCol()
    {
    while(1)
        {
            if ($Warning.isRotating())
            {
            Coll();
            }
            else
            {
            MoveRest();
            }
            
        sys.wait(0.001);
        }
    }

    void RotCol()
    {
    while(1)
        {
            if ($Warning.isRotating())
            {
            Coll();
            }
            else
            {
            RotateRandom();
            }
        sys.waitFrame();
        }
    }

    void main()
    {
        thread WarningStop();
        thread MoveRestCol();
        thread RotCol();
    }

    So I guess getting a higher speed means I have to find out how to get a greater distance in one loop (that always takes 0.0160 sec), without the escape ...

     

     

  3. There are different ways to let a script wait, like waitFrame() and wait()

    Does waitFrame() wait 1/60th of a second when the game runs at 60fps and 1/20th of a second at 20fps?

    If I use wait(0.01) or wait(0.001), it's a shorter wait period then waitFrame. What is the shortest "safe" wait period, and can a fast computer handle a shorter wait time then a slow computer?

  4. I'm working on a script for a random mover that will stay in an area that is set by boundries. Random-Mover.jpg

     

    Ok,  I erased the question for I have answers t most of it already. New script down here:

    Spoiler

    void Warning()
    {
        $Warning.rotate( '0 0 720' );
    }

    void WarningStop()
    {
    while (1)
        {
        $Warning.stopRotating();
        sys.waitFrame();
        }
    }


    void Collision()
    {
        while(1)
        {
            if ($Warning.isRotating())
            {
            $light_4.On();
            
            $Target1.rotateOnce('0 0 179');// 0 0 180
            sys.wait(0.1);//0.1
            $light_4.Off();
            }
        sys.waitFrame();
        }
    }


    void RotateRandom()
    {
        while(1)
        {

        float minY = 0;
        float maxY = 0;
        float Y = minY + sys.random(maxY - minY);
        
        float minZ = -60;//-60
        float maxZ = 60;//60
        float Z = minZ + sys.random(maxZ - minZ);
        
        vector R = ('0 0 0');
        R_y = R_y + Y;
        R_z = R_z + Z;
        
        $Target1.time (0.1);//0.1
        
        $Target1.rotateOnce (R);
        sys.wait(0.5);//0.5
        }
    }

    void Move()
    {
    while(1)
        {
        $Target1.speed (250); //250 max speed?
        $Target1.move(REL_LEFT , 1);
        sys.wait(0.005);//0.005
        }
    }

    void main()
    {
        thread Collision();
        thread RotateRandom();
        thread Move();
        thread WarningStop();
    }

     

     

     

     

     

    • Like 1
  5. Scripting the whole bat/moth seemed to be very difficult, so I made a simple script where a bat hunts after an object that moves by binding rotators and doors together:

    Although it takes some effort to implement in a map, the result is rather nice I think. It could, with some tweaking, also be used for other flying stuff ^^

  6. @AluminumHaste

    "bats move so fast you wouldn't be able to see any detail anyways". That is true.

    I made a new bat model, a bit bigger (can be scaled down ofc.), still very simple but without the glitches I got from modeling in DR in the smalest grid. Btw, the bat must be triggered one time before it starts hunting, so it could be lurking somewhere and fly out suddenly in front of you with a trigger multiple or something.

    • Like 3
  7. In the following video you see a little white cube that's a func_rotating on the x axis, randomishly triggered by a trigger_timer to invert rotation. Bound to that is the red square plane, that's also a func_rotating, but on the z axis. Bound to that is the little blue cube, that's a sliding door (auto open auto close) named Target.

    Bat Mechanics

    The Bat itself is green in the video and is made up of two wing shaped atdm:mover_door's (auto open auto close) bound to a func_mover named Bat (the body of the bat). With 2 little scripts, activated once by atdm:target_callscriptfunction's, the Bat is following and turnig towards the Target:

    void MoveToTarget()
    
    {
    
    	float min = 10;
    	float max = 20;
     	float rand = min + sys.random(max - min);
        $Bat.time (rand/30);
        $Bat.accelTime (0);
        $Bat.decelTime (0);
    	$Bat.moveTo( $Target );
        sys.wait (0.1);
    	sys.trigger($ScriptMove);
    
    }
    
    void LookAtTarget()
    {
    	vector direction=$Bat.getOrigin()-$Target.getWorldOrigin();
    	$Bat.setAngles(sys.VecToAngles(-direction)+'0 0 0');
    	sys.wait (0.1);
    	sys.trigger($ScriptLook);
    }

    If anyone wants a bat flying around in their mission, just pm me for the model and stuff : )

    • Like 3
    • Thanks 1
  8. At the workshop I was fiddling around with "stacking" sliding doors on 3 axis and a rotator at the bottom, adding some random triggers and all on different speeds, a semi random movement occurs. The nice thing about this is that you can have your object to go around an object in the middle.

    https://streamable.com/v5udl9

    Now I'm trying to put that into a script and I can get things moving already, but how could the movement be restricted?

    I think there are ways to detect when an entity touches an other entity, and when that occurs a change of direction can follow, but isn't that processor heavy?

    Other way could be to predefine the area by creating some sort of (alternative) monsterclip (to define no-go areas). But how to put that in a script?

     

  9. Great mission. I love puzzly stuff. Atmosphere is great in all parts, but the Citadel is just amazing : )

    Spoiler

    Had to look here for the bomb solution and couldn't grab 1 of the four things in the Chapel, but after leaving the room and getting back in I could grab it and got the objective completed. In the Prison there were a lot of "seems" going on. I played version 2.

     

    • Thanks 1
×
×
  • Create New...