Page 2 of 2 FirstFirst 12
Results 11 to 11 of 11

Thread: Xmodel Moving

  1. #11
    Sergeant serthy's Avatar
    Join Date
    Nov 2012
    Posts
    450
    Thanks
    96
    Thanked 296 Times in 188 Posts
    PHP Code:
    //ingame the only diff. between a misc_model and a misc_brushmodel is their classname
    //but you can handle them as the same 'model'
    //just gather all the party of your object and move them at the same time in the same way
    init()
    {
        
    level thread move_brushmodel();
        
    level thread move_brushmodels();
        
    level thread move_xmodel();
        
    level thread move_xmodels();
        
    level thread move_xmodel_and_brushmodel_1();
        
    level thread move_xmodel_and_brushmodel_2();
        
    level thread move_trigger();
        
    level thread link_trigger_and_move();
    }

    /* gather a brushmodel and move it */
    move_brushmodel()
    {
        
    brushmodel getEnt"brushmodelname" "targetname" );

        if( 
    isDefinedbrushmodel ) )    //if there is nothing to move, skip
            
    brushmodel thread moveMe();
    }

    /* gather an array of misc_brushmodels with the same 'targetname' and move them */
    move_brushmodels()
    {
        
    brushmodel_array getEntArray"brushmodelname" "targetname" );

        if( 
    isDefinedbrushmodel_array ) && brushmodel_array.size )    //if there is nothing to move, skip
        
    {
            for( 
    index index brushmodel_array.size index++ )
            {
                
    brushmodel brushmodel_array[index];

                if( 
    isDefinedbrushmodel ) )    //if there is nothing to move, skip
                    
    brushmodel thread moveMe();
            }
        }
    }
    /* see there is no difference between a misc_model and a misc_brushmodel */
    /* gather a misc_model and move it */
    move_xmodel()
    {
        
    xmodel getEnt"xmodelname" "targetname" );

        if( 
    isDefinedxmodel ) )    //if there is nothing to move, skip
            
    xmodel thread moveMe();
    }

    /* gather an array of misc_models with the same 'targetname' and move them */
    move_brushmodels()
    {
        
    xmodel_array getEntArray"xmodelname" "targetname" );

        if( 
    isDefinedxmodel_array ) && xmodel_array.size )    //if there is nothing to move, skip
        
    {
            for( 
    index index xmodel_array.size index++ )
            {
                
    xmodel xmodel_array[index];

                if( 
    isDefinedxmodel ) )    //if there is nothing to move, skip
                    
    xmodel thread moveMe();
            }
        }
    }
    /* move your object made out of 1 misc_brushmodel and 1 misc_model */
    move_xmodel_and_brushmodel_1()
    {
        
    xmodel getEnt"xmodelname" "targetname" );
        
    brushmodel getEnt"brushmodelname" "targetname" );

        if( 
    isDefinedxmodel ) )    //if there is nothing to move, skip
            
    xmodel thread moveMe();

        if( 
    isDefinedbrushmodel ) )    //if there is nothing to move, skip
            
    brushmodel thread moveMe();
    }

    /* move your object made out of misc_brushmodels and misc_models */
    move_xmodel_and_brushmodel_2()
    {
        
    entity_array getEntArray"entity_name" "targetname" );

        if( 
    isDefinedentity_array ) && entity_array.size )    //if there is nothing to move, skip
        
    {
            for( 
    index index entity_array.size index++ )
            {
                
    entity entity_array[index];

                if( 
    isDefinedentity ) )    //if there is nothing to move, skip
                    
    entity thread moveMe();
            }
        }
    }

    /* since you can only move script_origins, script_models, and script_brushmodels, you have to link your trigger to one of them before it will move! 
       or you will get an error like the following:
       'entity 123 is not a script_brushmodel, script_model, or script_origin: (file 'serthy/_test.gsc', line 217)  >> self movez( 1000.0 , 5.0 , 5.0 );'
    */

    link_trigger_and_move()
    {
        
    trigger getEnt"triggername" "targetname" );
        
    linker getEnt"linkername" "targetname" );

        if( !
    isDefinedtrigger ) )    //if there is nothing to move, skip
            
    return;

        if( !
    isDefinedlinker ) )//spawn a helper to move the trigger if there is none
            
    linker spawn"script_origin" trigger.origin );

        
    trigger enableLinkTo();
        
    trigger linkTolinker );
        
    linker thread moveMe();
    }

    moveMe()
    {
        if( !
    isDefinedself ) )    //if there is nothing to move, skip
            
    return;

        
    self moveToself.origin + ( 1000 ) , 10.0 5.0 2.0 );    //move 1000 in Z direction

    this is how I move my triggers, i implemented this in my _utility.gsc, you can do it for rotating etc. as well
    PHP Code:
    moveTriggerTopoint time acceleration*_time deceleration_time )
    {
        if( !
    isDefinedself ) )
            return;

        if( !
    isDefinedself.linkObject ) )
            
    self.linkObject spawn"script_origin" self.origin );

        if( !
    isDefinedself.enableLinkTo ) )
        {
            
    self enableLinkTo();
            
    self.enableLinkTo true;
        }

        
    self linkToself.linkObject );

        
    self moveTopoint time acceleration*_time deceleration_time );

    trigger enableLinkTo(); is only required by triggers, you don't need to call it on other entities
    Last edited by serthy; 1st January 2013 at 20:52. Reason: Edit said it

  2. The Following 2 Users Say Thank You to serthy For This Useful Post:

    kung foo man (2nd January 2013),Ni3ls (1st January 2013)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •